#include<iostream>
using namespace std;
int main()
{
    int time;
    cin>>time;
    while(time--)
    {
        int number;
        cin>>number;
        int* score=new int[number];
        int* point=score+number/2;
        //初始地址+数目/2
        for(int i=0;i<number;i++)
        {
            cin>>*(score+i);
        }
        int leftscore=*(--point);
        point++;
        int rightscore=*(++point);
        point--;
        //题目要用++ -- ，这样回去中间
        cout<<leftscore<<" "<<rightscore<<endl;
        int searchScore=0;
        cin>>searchScore;
        cout<<*(point+((searchScore-1)-number/2))<<endl;
        //point现在指向的是中间，那就让寻找的那个分数-中间位置得到位置差，位置差为负数表示在中间左边，为正数在中间右边
        delete[] score;
    }
}